package myjava.innerclassi;

public class Root7 {

   public static void main(String[] args) {

      Foo f = new Foo();
      Doer d = f.getDoer();
      d.dooo();
   }
}

class Foo {

   // method defined inner classes!
   public Doer getDoer() {

      // shit in here live on the stack
      // when the stack is over shit is over too
      final String sss = "e sti cazzi!";
      
      class Faa implements Doer {
         public void dooo() {
            // dooo uses stack shit
            System.out.println(sss);
         }
      }

      Faa o = new Faa();
      
      // but o is now on the heap as it is returned by the method and referenced elsewhere
      // sss (stack shit used by the Doer must therefore be FINAL)
      // does final shit defined int he stack live forever?
      // I DON'T KNOW!
      return o;
   }
}

interface Doer {
   void dooo();
}